<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ page import="factory.*,entity.*"%>
<%@ page import="java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>登录验证！</title>
</head>
<body>
	<%
		boolean flag = false;
		String keyWord = request.getParameter("username");
		if (keyWord == null) {
			keyWord = "";
		}
	%>
	<%
		User user = null;
		try {
			user = DAOFactory.getIEmpDAOInstance().findid(keyWord);
			if (user != null) {
				String passwd = user.getPassword();
				if (passwd != null
						&& passwd.equals(request.getParameter("password")))
					flag = true;
				else {
					session.setAttribute("error", "密码错误"); //用户存在，但密码不匹配
					response.setHeader("Refresh", "0;URL=error.jsp");
				}

			} else {
				session.setAttribute("error", "账号不存在"); //账号不存在
				response.setHeader("Refresh", "0;URL=error.jsp");
			}
		} catch (Exception e) {
		}

		if (flag) { //查询成功，跳转到主页面
			session.setAttribute("user", user);
			response.setHeader("Refresh", "0;URL=index.jsp");

		}
	%>
</body>
</body>
</html>